package com.mall507.fivepeaks.widget.xdialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.hzh.frame.util.AndroidUtil;
import com.mall507.fivepeaks.R;

/**
 * 用户签到补签提示框
 * */
public class XUserMainRetroactiveDialog{

	private Dialog alertDialog;
	
	
	/**
	 * @param context
	 * @param callback 选择结果回调
	 * */
	public void show(final Context context,final XUserMainRetroactiveDialogCallBack callback) {
		//防止网络延迟情况下多次点击弹出多个窗口
		dismiss();
		alertDialog = new Dialog(context, R.style.XDialog_RemoveAllStyle);
		LayoutInflater in = LayoutInflater.from(context);
		View viewDialog = in.inflate(R.layout.view_xdialog_user_main_retroactive, null);
		viewDialog.setMinimumHeight(AndroidUtil.getWindowHeight());
		viewDialog.setMinimumWidth(AndroidUtil.getWindowWith());
		Button confirm=(Button) viewDialog.findViewById(R.id.confirm);
		Button cancel=(Button) viewDialog.findViewById(R.id.cancel);
		confirm.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				dismiss();
				callback.confirm();
			}
		});
		cancel.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View view) {
				dismiss();
				callback.cancel();
			}
		});
		alertDialog.setContentView(viewDialog);
		// 点击对话框外部取消对话框显示
		alertDialog.setCanceledOnTouchOutside(false);
		alertDialog.show();
	}
	
	/**
	 * 关闭当前Dialog
	 * */
	public void dismiss(){
		if(alertDialog!=null && alertDialog.isShowing()){
			alertDialog.dismiss();
		}
	}
	
	/**
	 * 选择结果回调
	 * */
	public interface XUserMainRetroactiveDialogCallBack{
		  /**
		   * 确定
		   */
		  void confirm();
		  
		  /**
		   * 取消
		   */
		  void cancel();
	}
}
